<template>
  <div id="app" style="width: 400px">
    <el-form ref="form" :model="params" label-width="80px" v-loading="listLoading" class="el-form-css">
      <el-form-item label="用户名:">
        <el-input v-model="params.seekerName"></el-input>
      </el-form-item>
      <el-form-item label="性别:">
        <el-col :span="10">
          <el-radio-group v-model="params.sex">
            <el-radio :label=0>男</el-radio>
            <el-radio :label=1>女</el-radio>
          </el-radio-group>
        </el-col>
        <el-col :span="14">
        </el-col>
      </el-form-item>
      <el-form-item label="学历:">
        <el-select v-model="params.degree" placeholder="请选择最高学历">
          <el-option label="小学" :value=0></el-option>
          <el-option label="高中" :value=1></el-option>
          <el-option label="本科" :value=2></el-option>
          <el-option label="研究生" :value=3></el-option>
          <el-option label="博士" :value=4></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="地址:">
        <el-input type="textarea"  maxlength="250" show-word-limit :autosize="{ minRows: 3}"
                  v-model="params.address"
                  style="width: 300px"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit()">立即修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {getSeekerDetail, postSeekerDetail} from "@/api";

export default {
  name: "seeBaseInformation",
  data() {
    return {
      listLoading: false,
      params: {
        id: '',
        seekerName: '',
        sex: '',
        degree: '',
        address: ''
      },
    }
  },
  methods: {
    init() {
      this.listLoading = true
      getSeekerDetail(this.$route.query.id).then(res => {
        this.params = {}
        this.$set(this.params, 'id', res.data.id)
        this.$set(this.params, 'seekerName', res.data.seekerName)
        this.$set(this.params, 'sex', res.data.sex)
        this.$set(this.params, 'degree', res.data.degree)
        this.$set(this.params, 'address', res.data.address)
        this.listLoading = false
      })
    },
    onSubmit() {
      postSeekerDetail(this.params).then(res => {
        this.$message.success('修改成功！')
        return res
      })
    }
  },
  created() {
    this.init()
  }, mounted() {
    window.app = this
  }
}
</script>

<style scoped>
.el-form-css .el-input, .el-select {
  width: 300px;
}

</style>